import api from '../../../fetch/api'

export default {
    data() {
        return {

        }
    },
    created() {
    },
    methods: {
        // 重新生成按钮
        reBuild(){
            this.$refs.myReBuildBtn.reBuild()
        },
        getDefaultParams(){//获取不能缺少的默认的参数
            let self = this;
            let searchParams = self.searchParams,
                searchList = self.searchList,
                result = {};
                var itemreportDimension,itemdateFromTo;
                for (var key in searchList) {
                    if (searchList.hasOwnProperty(key)) {
                        var item = searchList[key];
                        if(item.name=='reportDimension'){
                            itemreportDimension = item;
                        }else if(item.name=='dateFromTo'){
                            itemdateFromTo = item;
                        }
                    }
                }
                if(!self.searchParams.reportDimension){
                    result.reportDimension = itemreportDimension.value;
                }
                if(!self.searchParams.statDateFromStr){
                    result.statDateFromStr = moment(itemdateFromTo.value[0]).format('YYYY-MM-DD HH:mm:ss');
                    result.statDateToStr = moment(itemdateFromTo.value[1]).format('YYYY-MM-DD HH:mm:ss');
                }
            return result;
        },
        getList() {
            var params = $.extend({}, this.searchParams, this.getDefaultParams(), this.otherParams);
            this.getItemList(params);
        },
        //获取列表
        getItemList(aparams) {
            let self = this,
                params = {
                    page: this.pageNumber,
                    rp: this.pageSize
                };
            params = $.extend({}, params, aparams);
            api.fetchGet('/report/payMode/pageList.do', params).then(res => {
                let data = res.data,
                    list = data.rows;
                self.tbodysInfo = list;
                self.total = data.total;
            }, err => { })
        },
        exportData() {
            let self = this;
            let params = {
            };
            params = $.extend({}, params, this.searchParams, this.getDefaultParams(), this.otherParams);
            self.showDialog("确认导出该报表?", '', function () {
                self.toExportAsync('/report/payMode/export.do', params);
            });
        },
        //查看详情
        showChargeWater(modalName, statDateDisplay, payModeByte, parkId) { 
            let self = this;
            var searchList = [{
                name: "query_time",
                value: statDateDisplay+" - "+statDateDisplay
            },
            {
                name: "query_payMode",
                value: payModeByte
            },
            {
                name: "parkIds",
                value: parkId
            }];

            self.detailSetData.searchList = searchList;      
            this.toOpenModal(modalName);
        },
    },
    filters: {

    }

}